package com.zp95sky.cloud.examples.mybatis.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.zp95sky.cloud.examples.mybatis.entity.T1;
import com.zp95sky.cloud.examples.mybatis.mapper.T1Mapper;
import com.zp95sky.cloud.examples.mybatis.service.TestService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TestServiceImpl implements TestService {

    @Resource
    private T1Mapper t1Mapper;

    @Override
    @DS("slave")
    public List<T1> getData() {
        return t1Mapper.selectList(null);
    }

    @Override
    @DS("slave")
    public List<T1> customGetData() {
        return t1Mapper.customSelectList();
    }

    @Override
    @DS("master")
    public void saveData(T1 t1) {
        t1Mapper.insert(t1);
    }

    @Override
    @DS("master")
    public void customSaveData(T1 t1) {
        t1Mapper.customInsert(t1);
    }

    @Override
    @DS("slave")
    public List<T1> customGetData2() {
        return t1Mapper.customSelectList2();
    }

    @Override
    @DS("master")
    public void customSaveData2(T1 t1) {
        t1Mapper.customInsert2(t1);
    }

    @Override
    public List<T1> customGetData3() {
        return t1Mapper.customSelectList3();
    }

    @Override
    public void customSaveData3(T1 t1) {
        t1Mapper.customInsert3(t1);
    }

    @Override
    public List<T1> customGetData4() {
        return t1Mapper.customSelectList4();
    }

    @Override
    public void customSaveData4(T1 t1) {
        t1Mapper.customInsert4(t1);
    }

}
